package com.aididi.entity.es;

import com.aididi.enums.FieldAnalyzer;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;

/**
 * @Auther: zx.xu
 * @Description:
 *      indexName:索引，type：类型，
 *      useServerConfiguration：true表示当Spring创建索引时,Spring不会在创建的索引中设置以下设置：shards,replicas,refreshInterval和indexStoreType，
 *      createIndex：是否创建索引，
 *      shards：默认索引分区数，
 *      replicas：每个分区的备份数，
 *      refreshInterval ：刷新间隔
 */
@Data
@Document(indexName = "elk-log",type = "eslog" ,
        useServerConfiguration = true,createIndex = false,shards = 1,replicas = 0,refreshInterval = "-1")
public class EsLog implements Serializable{

    @Id
    private Long id;
    @Field(type = FieldType.Text,analyzer = FieldAnalyzer.IK_MAX_WORD,searchAnalyzer = FieldAnalyzer.IK_SMART)
    private String name;
    @Field(type = FieldType.Integer)
    private Integer age;
    @Field(type = FieldType.Text,analyzer = FieldAnalyzer.IK_MAX_WORD,searchAnalyzer = FieldAnalyzer.IK_SMART)
    private String desc;
    @Field(type = FieldType.Date,format = DateFormat.custom,
            pattern = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis")
    private Date createTime;
    @Field(type = FieldType.Date,format = DateFormat.custom,
            pattern = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis")
    private Date updateTime;

}
